Skip to content

Conversation

@tomershafir
Copy link
Contributor

This patch adds a Clang-compatible --save-stats option to opt, to provide an easy to use way to save LLVM statistics files when working with opt on the middle end.

This is a follow up on the addition to llc: #163967

Like on Clang, one can specify --save-stats, --save-stats=cwd, and --save-stats=obj with the same semantics and JSON format. The pre-existing --stats option is not affected.

The implementation extracts the flag and its methods into the common CodeGen/CommandFlags as LLVM_ABI, using a new registration class to conservatively enable opt-in rather than let all tools take it. Its only needed for llc and opt for now. Then it refactors llc and adds support for opt.

@github-actions
Copy link

github-actions bot commented Nov 10, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

This patch adds a Clang-compatible --save-stats option to opt, to provide an easy to use way to save LLVM statistics files when working with opt on the middle end.

This is a follow up on the addition to `llc`: llvm#163967

Like on Clang, one can specify --save-stats, --save-stats=cwd, and --save-stats=obj with the same semantics and JSON format. The pre-existing --stats option is not affected.

The implementation extracts the flag and its methods into the common `CodeGen/CommandFlags` as `LLVM_ABI`, using a new registration class to conservatively enable opt-in rather than let all tools take it. Its only needed for llc and opt for now. Then it refactors llc and adds support for opt.
@tomershafir tomershafir marked this pull request as ready for review November 11, 2025 09:18
cl::init(false));
CGBINDOPT(DisableIntegratedAS);

#undef CGBINDOPT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be moved after RegisterSaveStatsFlag

Copy link
Contributor Author

@tomershafir tomershafir Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intentionally removed it because I dont think its needed anymore moving CGBINDOPT to a wider scope, becoming a redundant compile time overhead

@tomershafir tomershafir requested a review from dtcxzyw November 11, 2025 14:19
Copy link
Member

@dtcxzyw dtcxzyw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@tomershafir tomershafir merged commit 35ffe10 into llvm:main Nov 13, 2025
11 checks passed
@tomershafir tomershafir deleted the opt-save-stats branch November 13, 2025 14:03
tomershafir added a commit to swiftlang/llvm-project that referenced this pull request Nov 25, 2025
This patch adds a Clang-compatible --save-stats option to opt, to
provide an easy to use way to save LLVM statistics files when working
with opt on the middle end.

This is a follow up on the addition to `llc`:
llvm#163967

Like on Clang, one can specify --save-stats, --save-stats=cwd, and
--save-stats=obj with the same semantics and JSON format. The
pre-existing --stats option is not affected.

The implementation extracts the flag and its methods into the common
`CodeGen/CommandFlags` as `LLVM_ABI`, using a new registration class to
conservatively enable opt-in rather than let all tools take it. Its only
needed for llc and opt for now. Then it refactors llc and adds support
for opt.

(cherry-pick 35ffe10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants